/*
 * test_storage.c
 *
 *  Created on: 2014年7月22日
 *      Author: chens
 */

#include <cm/storage/cm_storage.h>
#include <string.h>
#include <cm/cm_time.h>

struct my_data {
	int a;
	char b;
	char c[21];
};

int main()
{
	cm_storage *storage = cmstorage_create(CM_STORAGE_FILE,
			sizeof(struct my_data), "./my_data.storage",
			NULL, NULL);

	if (storage == NULL)
		return 0;

//	struct my_data data;
//	memset(data.c, 0, sizeof(data.c));
//	data.a = 1;
//	data.b = 'A';
//	data.c[0] = 'A';
//
//	cmstorage_put(storage, &data, CM_STORAGE_NOMAL);

	struct cmstorage_head head;
	struct my_data data;
	cmstorage_get(storage, CM_STORAGE_SORT_DEFAULT, NULL, (char *) &data,
			sizeof(data), &head);
	printf("head: create time = %s\n", timeval2str(head.create_time));
	printf("data: a = %d, b = %c, c = %s\n", data.a, data.b, data.c);

}

